Test Series - java script

Test Number 29/92

Q: The URL property belongs to which of the following object?
A. Document
B. Element
C. Location
D. Event
Solution: The Document object has a URL property, which is a static string that holds the URL of the document when it was first loaded. If you want to access any element in an HTML page, you always start with accessing the document object.
Q: What does the location property represent?
A. Current DOM object
B. Current URL
C. Both DOM object and URL
D. Document
Solution: The location property of a window is a reference to a Location object; it represents the current URL of the document being displayed in that window.
Q: Which among the following is not a property of the Location object?
A. protocol
B. host
C. hostee
D. hostname
Solution: The location object is part of the window object and is accessed through the window.location property. The various properties of the location object are the protocol, host, hostname, port, search, and hash.
Q: What is the return type of the hash property?
A. Query string
B. Packets
C. String
D. Fragment identifier
Solution: The hash property sets or returns the anchor part of a URL. The hash property returns the “fragment identifier” portion of the URL if there is one a hash mark (#) followed by an element ID. It is accessed by using the statement location.hash.
Q: What is the function used to extract arguments from the search property of a URL?
A. urlArgs()
B. url()
C. hash()
D. geturl()
Solution: The urgArgs() function can be used to extract arguments from the search property of a URL. Search property can be accessed through the location object.
Q: The decodeURIComponent() is defined by _____________
A. Server-side JavaScript
B. Client-side JavaScript
C. Both Server-side and Client-side JavaScript
D. Service side JavaScript
Solution: The decodeURIComponent() is a global function defined by client-side JavaScript. The decodeURIComponent() function decodes a Uniform Resource Identifier (URI) component previously created by encodeURIComponent or by a similar routine.
Q: Which is the method that removes the current document from the browsing history before loading the new document?
A. modify()
B. assign()
C. replace()
D. remove()
Solution: The replace() removes the current document from the browsing history before loading the new document. The difference between assign method and replace(), is that replace() removes the URL of the current document from the document history, meaning that it is not possible to use the “back” button to navigate back to the original document.
Q: Why is the replace() method better than the assign() method?
A. Reliable
B. Highly manageable
C. More efficient
D. Handles unconditional loading
Solution: The difference between assign method and replace(), is that replace() removes the URL of the current document from the document history, meaning that it is not possible to use the “back” button to navigate back to the original document. When a script unconditionally loads a new document, the replace() method is often a better choice than assign().
Q: What is the purpose of the assign() method?
A. Only loading
B. Loading of window and display
C. Displays already present window
D. Unloading of window
Solution: The assign() method of the Location object makes the window load and display the document at the URL you specify. The difference between this method and replace(), is that replace() removes the URL of the current document from the document history, meaning that it is not possible to use the “back” button to navigate back to the original document.
Q: The history property belongs to which object?
A. Element
B. Window
C. History
D. Location
Solution: The history property of the Window object refers to the History object for the window. The history object is part of the window object and is accessed through the window.history property.

You Have Score    /10